package com.kmust.dream.wanderingdream.donation.dao;

import com.kmust.dream.wanderingdream.donation.entity.DonationThingsEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 
 * 
 * @author Leng
 * @email Leng81605@gmail.com
 * @date 2021-07-12 21:35:52
 */
@Mapper
public interface DonationThingsDao extends BaseMapper<DonationThingsEntity> {
    @Select("SELECT * FROM `donation_things`")
    List<DonationThingsEntity> list();

    /**
     * 根据用户昵称查询参与的捐赠活动
     * @param nickname
     * @return
     */
    @Select("SELECT * FROM donation_things WHERE nick_name = #{nickname}")
    List<DonationThingsEntity> getListByNickName(String nickname);

    /**
     * 根据用户名返回参与的捐赠活动
     * @param username
     * @return
     */
    @Select("SELECT * FROM donation_things WHERE recipient_id in (SELECT recipient_id FROM recipient_user_union WHERE username = #{username})")
    List<DonationThingsEntity> getListByUserName(String username);


}
